<template>
	<view>
		<u-navbar :is-back="false" title="　" :border-bottom="false">
			<view class="u-flex u-row-right" style="width: 100%;">
				<view class="camera u-flex u-row-center">
				</view>
			</view>
		</u-navbar>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="form.imageUrl" size="140"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20" v-model="form.userName">{{form.userName}}</view>
				<view class="u-font-14 u-tips-color" v-model="form.jobNumber">员工工号:{{form.jobNumber}}</view>
			</view>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="account" title="个人信息" @click="toPersonInfo"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="order" title="绑定工位" @click="toBindPage"></u-cell-item>
				<u-cell-item icon="red-packet" title="绩效查询" @click="toPerformancePage"></u-cell-item>
				<u-cell-item icon="error" title="异常上传" @click="abnormalUpload" v-if="!unview"></u-cell-item>
				<u-cell-item icon="list-dot" title="排产设置" @click="toSetNumber" v-if="!unview"></u-cell-item>
				<u-cell-item icon="file-text" title="设备点检" @click="toSpotCheckList('设备点检')"></u-cell-item>
				<u-cell-item icon="file-text" title="设备保养" @click="toSpotCheckList('设备保养')"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
import { accessPersonInfo } from '../../utils/index.js'
	export default {
		data() {
			return {
				form: {
					userName:'',					//用户姓名
					jobNumber:'',					//员工工号
					imageUrl:''						//用户头像
				},
				unview: false
			}
		},
		// 进入home页面即获取该用户信息
		onLoad() {
			this.getUserInfo()
			if(uni.getStorageSync('user').departmentName == '喷涂车间') { this.unview = true }
		},
		methods: {
			toSpotCheckList(name){
				uni.navigateTo({
					url:'../../publicPage/spotCheckList?name=' + name
				})
			},
			// 跳转到公共的用户信息页面
			toPersonInfo(){
				uni.navigateTo({
					url:'../../publicPage/personInfo'
				})
			},
			// 跳转绩效查询页面
			toPerformancePage(){
				uni.navigateTo({
					url:'../../publicPage/performance'
				})
			},
			// 跳转到公共的用户工位绑定页面
			toBindPage(){
				uni.navigateTo({
					url:'./bindPage'
				})
			},
			// 异常上传
			abnormalUpload() {
				uni.navigateTo({
					url:'./abnormal'
				})
			},
			// 跳转到排产界面
			toSetNumber() {
				uni.navigateTo({
					url:'./setNumber'
				})
			},
			// 获取用户信息函数
			async getUserInfo(){
				const {data} = await accessPersonInfo()
				this.form = Object.assign({},data.data)
				uni.setNavigationBarTitle({
					title: this.form.departmentName == '焊接车间'?'焊接车间员工':this.form.departmentName == '喷涂车间'?'喷涂车间员工':'数控车间员工'
				});
				// uni.setNavigationBarTitle({
				// 	title: data.data.departmentName
				// });
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color: #ededed;
}

.camera{
	width: 54px;
	height: 44px;
	
	&:active{
		background-color: #ededed;
	}
}
.user-box{
	background-color: #fff;
}
</style>